Create Database VoThiSau
Go

use VoThiSau
Go

Create Table NamHoc
(
   MaNH int primary key identity not null,
   NienKhoa varchar(20) not null
)
Go

Create Table LopHoc
( 
   MaLop int primary key  identity not null,
   TenLop varchar(20) unique not null,
   Khoi int not null
)
Go

Create Table NhomTinTuc
(
   MaNhomTT int primary key identity not null,
   TenNhomTT nvarchar(50) not null
)
Go

Create Table TinTuc
(
   MaTT int primary key identity not null,
   NhomTT int foreign key references NhomTinTuc(MaNhomTT),
   HinhAnh varchar(50),
   MieuTa nvarchar(200) not null,
   NoiDung nvarchar(max) not null,
   NgayDang datetime not null,
   TinNoiBat bit
)
Go

Create Table GiaoVien
(
   MaGV int primary key identity not null,
   HoTen nvarchar(100) not null,
   GioiTinh bit not null,
   NgaySinh datetime not null,
   CMDaoTao nvarchar(50),
   DiaChi nvarchar(200) not null,
   DienThoai varchar(20),
   HinhAnh varchar(50),
   MieuTa nvarchar(max)
)
Go

Create Table QuanTri
(
   MaQT int primary key identity not null,
   TaiKhoan nvarchar(50) unique not null,
   MatKhau nvarchar(50) not null,
   HoTen nvarchar(50) not null
)
Go

Create Table GioiThieu
(
   MaGT int primary key identity not null,
   TenGT nvarchar(50) not null,
   NoiDung nvarchar(max) not null
)
Go

Create Table KeHoach
(
   MaKH int primary key identity not null,
   NamHoc int foreign key references NamHoc(MaNH) not null,
   TenKH nvarchar(50) not null,
   NoiDung nvarchar(max) not null
)
Go

Create Table PCChuyenMon
(
   MaPC int primary key identity not null,
   NamHoc int foreign key references NamHoc(MaNH) not null,
   NoiDung nvarchar(max)
)
Go

Create Table KQHocSinh
(
   MaKQ int primary key identity not null,
   NamHoc int foreign key references NamHoc(MaNH) not null,
   HocKy bit,
   Lop int foreign key references LopHoc(MaLop) not null,
   LoaiKQ nvarchar(50) not null,
   NoiDung nvarchar(max) not null
)
Go

Create Table TrangVang
(
   MaTV int primary key identity not null,
   HoTen nvarchar(100) not null,
   VaiTro bit,
   ThanhTich nvarchar(200),
   TrenTrangChu bit,
   NamHoc int foreign key references NamHoc(MaNH) not null,
   Lop int foreign key references LopHoc(MaLop) not null,
   MieuTa nvarchar(max)
)
Go

Create Table LienKet
(
   MaLK int primary key identity not null,
   TenLK nvarchar(100) not null,
   LinkLK varchar(500) not null,
   HinhAnh varchar(50)
)
Go

Create Table LienHe
(
   MaLH int primary key identity not null,
   TieuDe nvarchar(500) not null,
   NoiDung nvarchar(max) not null,
   Email nvarchar(150),
   DiaChi nvarchar(250),
   Ten nvarchar(200),
   DienThoai varchar(20)
)
Go

Create Table ThoiKhoaBieu
(
   MaTKB int primary key identity not null,
   Khoi int not null,
   NamHoc int foreign key references NamHoc(MaNH) not null,
   HocKy bit,
   ThoiKhoaBieu nvarchar(max) not null
)
Go

Create table TaiNguyen
(
	MaTN int primary key identity,
	TenFile nvarchar(50) not null,
	Kieu bit,
	MoTa nvarchar(50)
)